<template>
  <template v-for="item in menuList" :key="item.path">
    <template v-if="!item.meta.hidden">
      <template v-if="item.children?.length">
        <template v-if="item.meta.level">
          <!-- 是否是首页 -->
          <el-menu-item :index="item.children[0].path" v-if="!item.children[0].meta.hidden">
            <el-icon>
              <component :is="item.children[0].meta.icon"></component>
            </el-icon>
            <template #title>
              <span>{{ item.children[0].meta.title }}</span>
            </template>
          </el-menu-item>
        </template>
        <el-sub-menu v-else :index="item.path">
          <template #title>
            <el-icon>
              <component :is="item.meta?.icon"></component>
            </el-icon>
            <span>{{ item.meta?.title }}</span>
          </template>
          <!-- 递归 -->
          <Menu :menuList="item.children" />
        </el-sub-menu>
      </template>
      <el-menu-item v-else :index="item.path">
        <el-icon>
          <component :is="item.meta?.icon"></component>
        </el-icon>
        <template #title>
          <span>{{ item.meta?.title }}</span>
        </template>
      </el-menu-item>
    </template>
  </template>
</template>

<script setup lang="ts">
defineProps(['menuList'])
</script>
<script lang="ts">
export default {
  name: 'Menu',
}
</script>

<style scoped></style>
